﻿using DevExpress.XtraCharts;
using DevExpress.XtraReports.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;

namespace DXWinformReport
{
    public partial class XtraReport6 : DevExpress.XtraReports.UI.XtraReport
    {
        public XtraReport6()
        {
            InitializeComponent();
            DataSource = GetClassCounts();
            xrChart1.DataSource = GetClassCounts();
            xrChart1.Series[0].ArgumentDataMember = "ClassName";
            xrChart1.Series[0].ValueDataMembers[0] = "StudentCount";
            xrChart1.Series[0].Name = "班级人数";
            xrChart1.Series[0].Label.TextPattern = "{A} 人数：{V}";

            xrChart2.DataSource = GetClassCounts();
            xrChart2.Series[0].ArgumentDataMember = "ClassName";
            xrChart2.Series[0].ValueDataMembers[0] = "StudentCount";
            xrChart2.Series[0].Name = "班级人数百分比";
            xrChart2.Series[0].Label.TextPattern = "{A} :{VP:0.00%}";
        }

        private List<ClassModel> GetClassCounts()
        {
            return new List<ClassModel>()
            {
                new ClassModel(){ClassId=1,ClassName="一班", StudentCount=30},
                new ClassModel(){ClassId=2,ClassName="二班",StudentCount=40},
                new ClassModel(){ClassId=3,ClassName="三班",StudentCount=35},
                new ClassModel(){ClassId=4,ClassName="四班",StudentCount=28},
                new ClassModel(){ClassId=5,ClassName="五班",StudentCount=39}
            };
        }

    }

    public class ClassModel
    {
        public int ClassId { get; set; }

        public string ClassName { get; set; }
        public int StudentCount { get; set; }
    }
}
